package com.starhub.web.host.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.http.ResponseEntity;

import com.starhub.web.host.StarHubBaseHost;
import com.starhub.web.host.TileHost;
import com.starhub.web.model.Tile;

public class TileHostImpl extends StarHubBaseHost implements TileHost {

	public List<Tile> getTiles(int categoryId) {
		ResponseEntity<Tile[]> response = restTemplate.getForEntity("http://localhost:8080/StarHub/getTiles?categoryId=" + String.valueOf(categoryId), Tile[].class);
		return Arrays.asList(response.getBody());
	}

	public Tile getTileDetails(int tileId) {
		return restTemplate.getForObject("http://localhost:8080/StarHub/getTileDetails?tileId=" + String.valueOf(tileId), Tile.class);
	}
	
	public void updateTile(Tile tile) {
		restTemplate.postForObject("http://localhost:8080/StarHub/updateTile", tile, Tile.class);
	}
}
